package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.FoundGoodTitleBeen;

/**
 * @author gzk
 * @date 2020/9/1 0001
 * description：
 */
public class TabFragmentAdapter extends FragmentPagerAdapter {
    private List<FoundGoodTitleBeen.DataBean> mTitleList;
    private Context mContext;
    private List<Fragment> mFragments;

    public TabFragmentAdapter(List<Fragment> fragments, List<FoundGoodTitleBeen.DataBean> mTitleList, FragmentManager fm, Context context) {
        super(fm);
        this.mContext = context;
        this.mFragments = fragments;
        this.mTitleList = mTitleList;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mTitleList.size();
    }


    public View getTabView(int position) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_tablayout_header, null);
        TextView tv_title=view.findViewById(R.id.tv_tablayout_title);
        TextView tv_content=view.findViewById(R.id.tv_tablayout_content);
        tv_title.setText(mTitleList.get(position).getName());
        tv_content.setText(mTitleList.get(position).getSubtitle());
        return view;
    }
}
